import java.util.Arrays;

public class demo3 {
    public static <T> String print2DArray(T[][] array) {
        if (array == null) {
            return "[]";
        }

        StringBuilder result = new StringBuilder("[");
        for (int i = 0; i < array.length; i++) {
            if (array[i] == null) {
                result.append("null");
            } else {
                result.append(Arrays.toString(array[i]));
            }
            if (i < array.length - 1) {
                result.append(", ");
            }
        }
        result.append("]");
        return result.toString();
    }

    public static void main(String[] args) {
        // 测试用例
        int[][] intArray = {{1, 2}, {3, 4}, {5}};
        String[][] stringArray = {{"a", "b"}, {"c", "d"}, null};
        Object[][] emptyArray = {};

        System.out.println(print2DArray(intArray));
        System.out.println(print2DArray(stringArray));
        System.out.println(print2DArray(emptyArray));
    }
}